#!/usr/bin/env bash


set -e -u -x
source ./tasks/helpers.sh

nodejs_version="20.15.1"
nodejs_hash="26700f8d3e78112ad4a2618a9c8e2816e38a49ecf0213ece80e54c38cb02563f"

download_arch="$TARGETARCH"
if [ "$TARGETARCH" == "amd64" ]; then
  download_arch="x64"
elif [ "$TARGETARCH" == "arm64" ]; then
  nodejs_hash="10d47a46ef208b3e4b226e4d595a82659123b22397ed77b7975d989114ec317e"
fi

task_working_dir
download "https://nodejs.org/dist/v$nodejs_version/node-v$nodejs_version-linux-${download_arch}.tar.xz" "sha256" "$nodejs_hash"
extract_download "node-v$nodejs_version-linux-${download_arch}.tar.xz"

mkdir -p "$DEV_INSTALL_PREFIX"
rsync -a --itemize-changes "node-v$nodejs_version-linux-${download_arch}/" "$DEV_INSTALL_PREFIX/"

stamp
